package com.bgs.controller;

import com.bgs.pojo.FinWrite;
import com.bgs.pojo.Finance;
import com.bgs.pojo.Invoice;
import com.bgs.pojo.Writeoff;
import com.bgs.service.WriteoffService;
import com.bgs.tool.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: xkgc
 * @description:
 * @author: Mr.Zhao
 * @create: 2022-05-17 21:05
 */
@RestController
@RequestMapping("/zsl")
public class WriteoffController {

    @Autowired
    private WriteoffService writeoffService;


    @GetMapping("/findAllWriteoff")
    public R findAllWriteoff(@RequestParam(defaultValue = "") String ordernumber, @RequestParam(defaultValue = "") Integer type){

        List<Writeoff> list= writeoffService.findAllFinance(ordernumber,type);


        return  R.ok().data("records",list);
    }

    @PostMapping("/shenFvo")
    public R shenFvo(@RequestBody Invoice invoice) {

        int a= writeoffService.shenFvo(invoice);

        if (a>0){
            return R.ok().message("申请成功");
        }else {
            return  R.error().message("支付失败");
        }

    }


}
